package com.vhall.component.plugin.core.service.dto;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 大数据-观看数据上报请求
 *
 * @author yuanzh
 * @date 2021/11/26
 */
@Data
@NoArgsConstructor
public class BigDataBroadcastRecordReportDTO implements Serializable {

    private static final long serialVersionUID = 4449047748817194338L;

    /**
     * required 活动ID，组件使用il_id
     */
    @JSONField(name = "activity_id")
    private String activityId;

    /**
     * required B端用户ID，组件采用主持人id
     */
    @JSONField(name = "business_id")
    private String businessId;

    /**
     * required B端用户父ID
     * 如果没有父账号，子账号与父账号一致
     */
    @JSONField(name = "business_parent_id")
    private String businessParentId;

    /**
     * required 应用id
     */
    @JSONField(name = "app_id")
    private String appId;

    /**
     * required 直播房间id
     */
    @JSONField(name = "live_room")
    private String liveRoom;

    /**
     * required 互动房间id
     */
    @JSONField(name = "inav_room")
    private String inavRoom;

    /**
     * required 聊天房间id
     */
    @JSONField(name = "chat_room")
    private String chatRoom;

    /**
     * required 活动开始时间，格式yyyy-MM-dd HH:mm:ss
     */
    @JSONField(name = "start_time", format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    /**
     * required 活动结束时间，格式yyyy-MM-dd HH:mm:ss
     */
    @JSONField(name = "end_time", format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    public static class Builder {

        private final BigDataBroadcastRecordReportDTO recordReport;

        public Builder() {
            this.recordReport = new BigDataBroadcastRecordReportDTO();
        }

        public BigDataBroadcastRecordReportDTO build() {
            return this.recordReport;
        }

        public BigDataBroadcastRecordReportDTO.Builder setAppId(String appId) {
            this.recordReport.setAppId(appId);
            return this;
        }

        /**
         * 设置所有房间id相关参数
         *
         * @param liveRoomId 直播房间id
         * @param inavRoomId 互动房间id
         * @param chatRoomId 聊天房间id
         * @return builder
         */
        public BigDataBroadcastRecordReportDTO.Builder setRoomIds(String liveRoomId, String inavRoomId, String chatRoomId) {
            this.recordReport.setLiveRoom(liveRoomId);
            this.recordReport.setInavRoom(inavRoomId);
            this.recordReport.setChatRoom(chatRoomId);
            return this;
        }

        /**
         * 设置所有时间相关参数
         *
         * @param startTime 活动开始时间
         * @param endTime   活动结束时间
         * @return builder
         */
        public BigDataBroadcastRecordReportDTO.Builder setTime(LocalDateTime startTime, LocalDateTime endTime) {
            this.recordReport.setStartTime(startTime);
            this.recordReport.setEndTime(endTime);
            return this;
        }

        /**
         * 设置活动id
         *
         * @param activityId 活动ID，组件使用il_id
         * @return builder
         */
        public BigDataBroadcastRecordReportDTO.Builder setActivityId(String activityId) {
            this.recordReport.setActivityId(activityId);
            return this;
        }

        /**
         * 设置活动id
         *
         * @param businessUserId B端用户ID，组件使用主持人id
         * @return builder
         */
        public BigDataBroadcastRecordReportDTO.Builder setUserId(String businessUserId) {
            this.recordReport.setBusinessId(businessUserId);
            this.recordReport.setBusinessParentId(businessUserId);
            return this;
        }
    }
}
